package com.rzj.sys_lab_assistant.service.impl;

import com.rzj.sys_lab_assistant.dao.InterviewMapper;
import com.rzj.sys_lab_assistant.entity.Interview;
import com.rzj.sys_lab_assistant.service.IInterviewService;
import com.rzj.sys_lab_assistant.utils.TimeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: sys_lab_assistant
 * @description:
 * @author: 作者
 * @create: 2021-07-01 15:43
 */
@Service
public class InterviewServiceImpl implements IInterviewService {

    @Autowired
    InterviewMapper interviewMapper;

    TimeUtils timeUtils;

    @Override
    public List<Interview> InterviewsList(int postId) {
        return interviewMapper.listInterviews(postId);
    }

    @Override
    public List<Interview> InterviewsByNoList(String studentNo) {
        return interviewMapper.listInterviewByNo(studentNo);
    }

    @Override
    public Interview getInterviewById(int id) {
        return interviewMapper.getInterviewById(id);
    }

    @Override
    public int getLabByNo(String studentNo) {
        return interviewMapper.getLabByNo(studentNo);
    }

    @Override
    public int addInterview(Interview interview) {
        interview.setCreateTime(timeUtils.getTime());
        interview.setModifyTime(timeUtils.getTime());
        return interviewMapper.saveInterview(interview);
    }

    @Override
    public int updateInterview(Interview interview) {
        interview.setModifyTime(timeUtils.getTime());
        return interviewMapper.updateInterview(interview);
    }

    @Override
    public int delInterview(int id) {
        return interviewMapper.deleteInterview(id);
    }
}
